package com.bt.lms.service.impl;

import com.bt.lms.entity.RegisterInfo;
import com.bt.lms.dao.servise.StuStatusRegisterInfoDao;
import com.bt.lms.dao.servise.impl.StuStatusRegisterInfoDaoImpl;
import com.bt.lms.service.StuStatusRegisterInfoService;

import java.sql.SQLException;

/**
 * 学籍注册信息接口实现
 */
public class StuStatusRegisterInfoServiceImpl implements StuStatusRegisterInfoService {
    @Override
    public boolean edit(Long id, RegisterInfo registerInfo) throws SQLException {
        StringBuilder registerSqlSB = new StringBuilder();
        registerSqlSB.append("update register_info set")
                .append(" register_state = ?,register_date = ?,goto_date = ?,no_register_cause = ? ")
                .append(",no_register_goto = ?,isvacate = ?,school_year = ?,semester = ?,classroom = ?")
                .append(" where deleted = ? and stu_status_Info_id = ?");
        String sql = new String(registerSqlSB);


        StuStatusRegisterInfoDao stuStatusRegisterInfoDao = new StuStatusRegisterInfoDaoImpl();
        stuStatusRegisterInfoDao.update(sql,registerInfo,id);


        return false;
    }
    @Override
    public boolean delete(Long id) throws SQLException {
        String sql = "update register_info set deleted = ? where stu_status_Info_id = ?";

        //掉dao方法
        StuStatusRegisterInfoDao stuStatusRegisterInfoDao = new StuStatusRegisterInfoDaoImpl();
        stuStatusRegisterInfoDao.delete(sql,id);

        return false;
    }

    @Override
    public boolean add(Long id, RegisterInfo registerInfo) throws SQLException {

        StringBuilder addRegisterSqlSB = new StringBuilder();
        addRegisterSqlSB.append("insert into register_info(")
                .append("register_state,register_date,goto_date,no_register_cause,no_register_goto")
                .append(",isvacate,school_year,semester,classroom)")
                .append(" values (?,?,?,?,?,?,?,?,?)");
        String sql = new String(addRegisterSqlSB);

        //掉dao方法
        StuStatusRegisterInfoDao stuStatusRegisterInfoDao = new StuStatusRegisterInfoDaoImpl();
        stuStatusRegisterInfoDao.insert(sql,registerInfo);

        return true;
    }
}
